﻿using System;
using System.Collections.Generic;
using System.Text;

using DotSpatial.Drawing;
using System.Drawing;
using System.Drawing.Design ;
using DotSpatial.Components;

using DotSpatial.Geometries;
using DotSpatial.Map;
using DotSpatial.Data;

using System.ComponentModel ;
using System.ComponentModel.Design ;
using System.Windows.Forms ;
using System.Windows.Forms.Design ;


namespace HuanGis
{

   


    public class FELineLayer : FEditableLayer
    {

        public FELineLayer(string id):base(id)
        {

            this.m_Type = FeatureTypes.Line;
        }




        #region "属性封装"

        private object _LineSymbol = new LineSymbolizer();

        [Editor(typeof(LineSymbolEditor), typeof(UITypeEditor))]
        [Category("基本信息"),DisplayName ("线基本信息设置")]
        public object LineSymbol
        {
            get { return _LineSymbol; }
            set
            {
                this._LineSymbol = value;
                this.OnSetSymbol();
            }
        }

        protected void OnSetSymbol()
        {
            if (this.BRunning)
                (this.ILayer as IFeatureLayer).Symbolizer = (LineSymbolizer)this._LineSymbol;
        }

        //-------------------------------------------------------

        private object _SelectSymbol = new LineSymbolizer();

        [Editor(typeof(LineSymbolEditor), typeof(UITypeEditor))]
        [Category("基本信息"), DisplayName("所选图形信息设置")]
        public object SelectionSymbol
        {
            get { return _SelectSymbol; }
            set
            {
                this._SelectSymbol = value;
                this.OnSetSelectSymbol();
            }
        }

        protected void OnSetSelectSymbol()
        {
            if (this.BRunning)
                (this.ILayer as IFeatureLayer).Symbolizer = (LineSymbolizer)this._SelectSymbol;
        }




        #endregion


        public override void AddShape(FShape shp)
        {
            if (shp.normalPts == null || shp.normalPts.Count < 2) return;

            base.AddShape(shp);

            Shape lineshp = new Shape(FeatureTypes.Line);
            lineshp.AddPart(shp.normalPts.ToArray(), CoordinateTypes.Regular);

            Feature f = new Feature(lineshp);
            if (f != null)
                (this.ILayer.DataSet as IFeatureSet).Features.Add(f);

        }

        public override void AddShapeRane(List<FShape> lstShp)
        {
            base.AddShapeRane(lstShp);

            for (int i = 0; i < lstShp.Count; i++)
            {
                this.AddShape(lstShp[i]);
            }

        }

       

      
    }
}
